package com.ruoyi.gzmx_tag_current.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gzmx_tag_current.domain.Gzmx_tag_current;
import com.ruoyi.gzmx_tag_current.service.IGzmx_tag_currentService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采集数据点位当前记录Controller
 * 
 * @author ruoyi
 * @date 2022-11-26
 */
@Controller
@RequestMapping("/gzmx_tag_current/gzmx_tag_current")
public class Gzmx_tag_currentController extends BaseController
{
    private String prefix = "gzmx_tag_current/gzmx_tag_current";

    @Autowired
    private IGzmx_tag_currentService gzmx_tag_currentService;

    @RequiresPermissions("gzmx_tag_current:gzmx_tag_current:view")
    @GetMapping()
    public String gzmx_tag_current()
    {
        return prefix + "/gzmx_tag_current";
    }

    /**
     * 查询采集数据点位当前记录列表
     */
    @RequiresPermissions("gzmx_tag_current:gzmx_tag_current:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Gzmx_tag_current gzmx_tag_current)
    {
        startPage();
        List<Gzmx_tag_current> list = gzmx_tag_currentService.selectGzmx_tag_currentList(gzmx_tag_current);
        return getDataTable(list);
    }

    /**
     * 导出采集数据点位当前记录列表
     */
    @RequiresPermissions("gzmx_tag_current:gzmx_tag_current:export")
    @Log(title = "采集数据点位当前记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Gzmx_tag_current gzmx_tag_current)
    {
        List<Gzmx_tag_current> list = gzmx_tag_currentService.selectGzmx_tag_currentList(gzmx_tag_current);
        ExcelUtil<Gzmx_tag_current> util = new ExcelUtil<Gzmx_tag_current>(Gzmx_tag_current.class);
        return util.exportExcel(list, "采集数据点位当前记录数据");
    }

    /**
     * 新增采集数据点位当前记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存采集数据点位当前记录
     */
    @RequiresPermissions("gzmx_tag_current:gzmx_tag_current:add")
    @Log(title = "采集数据点位当前记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Gzmx_tag_current gzmx_tag_current)
    {
        return toAjax(gzmx_tag_currentService.insertGzmx_tag_current(gzmx_tag_current));
    }

    /**
     * 修改采集数据点位当前记录
     */
    @RequiresPermissions("gzmx_tag_current:gzmx_tag_current:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Gzmx_tag_current gzmx_tag_current = gzmx_tag_currentService.selectGzmx_tag_currentById(id);
        mmap.put("gzmx_tag_current", gzmx_tag_current);
        return prefix + "/edit";
    }

    /**
     * 修改保存采集数据点位当前记录
     */
    @RequiresPermissions("gzmx_tag_current:gzmx_tag_current:edit")
    @Log(title = "采集数据点位当前记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody Gzmx_tag_current gzmx_tag_current)
    {
        gzmx_tag_current.setUpdateBy(getLoginName());
        return toAjax(gzmx_tag_currentService.updateGzmx_tag_current(gzmx_tag_current));
    }

    /**
     * 删除采集数据点位当前记录
     */
    @RequiresPermissions("gzmx_tag_current:gzmx_tag_current:remove")
    @Log(title = "采集数据点位当前记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gzmx_tag_currentService.deleteGzmx_tag_currentByIds(ids));
    }
}
